using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Deepcode.Flux.Core.Systems.Workflow;
using Deepcode.Flux.Core.Systems.Workflow.Bases;

using Deepcode.Flux.Core.Services.State;
using Example.Workflow.Objects;

public partial class extensions_exampleworkflow_forms_ui_WFViewForm : Deepcode.Flux.Core.UI.AdministrationModulePage
{
	#region ViewState storage
	/// <summary>
	/// Stores the ID of the task that is manipulating a piece of data
	/// </summary>
	public int TaskID
	{
		get
		{
			object o = ViewState["TaskID"];
			if( o == null ) return -1;
			return (int) o;
		}
		set
		{
			ViewState["TaskID"] = value;
		}
	}
	/// <summary>
	/// Stores the ID of the data being edited
	/// </summary>
	public int RecordID
	{
		get
		{
			object o = ViewState["RecordID"];
			if (o == null) return -1;
			return (int)o;
		}
		set
		{
			ViewState["RecordID"] = value;
		}
	}
	#endregion
	#region Page Load Event
	/// <summary>
	/// Page Load event
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			// Store any state information from the calling listing
			this.RecordID = GetAttribute("ID", -1);
			this.TaskID = GetAttribute("TaskID", -1);

			TelephoneBook book = new TelephoneBook();
			TelephoneBookEntry entry = book.GetTelephoneBookByID( this.RecordID );
			if( entry == null ) GoBack();

			fName.Text = entry.Name;
			fTel.Text = entry.Tel;
			fNotes.Text = entry.Notes.Replace("\n", "<br/>");
			fHistory.Text = entry.ApprovalHistory.Replace("\n", "<br/>");

			WFHeader.TaskID = this.TaskID;
		}
	}
	#endregion
	#region Navigation
	/// <summary>
	/// Return to the taskpad
	/// </summary>
	protected void GoBack()
	{
		Response.Redirect("~/admin/menu/taskpad.aspx", true);
	}
	#endregion
}
